﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="XunJia.aspx.cs" Inherits="PropertyAppraisal.XunJia" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link rel="stylesheet" type="text/css" href="../easyui/easyui/1.3.2/themes/default/easyui.css" />
    <link rel="stylesheet" type="/text/css" href="../easyui/easyui/1.3.2/themes/icon.css" />
    <script src="../easyui/easyui/1.3.2/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="../easyui/easyui/1.3.2/jquery.easyui.min.js"></script>
    <script src="../easyui/easyui/1.3.2/easyloader.js"></script>
    <script type="text/javascript" src="../easyui/jquery.params.js"></script>
<%--转换时间格式--%>
     <script src="../Tools/TimeJs.js"></script> <script src="../easyui/easyui/1.3.2/locale/easyui-lang-zh_CN.js"></script>
 <script src="../easyui/easyui/1.3.2/locale/easyui-lang-zh_CN.js"></script>
</head>
<body>
    <div fit="true">
        <div style="padding: 3px">
            <a href="javascript:void(0) " class="easyui-linkbutton" data-options="iconCls:'icon-add',toggle:true" onclick="addxun()">新增询价</a>
        </div>
            <iframe width="0" height="0" src="../SessionKeeper.aspx"></iframe>   
        <table id="dg" title="询价列表" style="width: 1190px; height: 600px" data-options="
				rownumbers:true,
				singleSelect:true,
				autoRowHeight:false,
				pagination:true,
				pageSize:10">
            <thead>
                <tr>
                    <th field="bianId" width="100">编号</th>
                    <th field="xiangId" width="100">项目号</th>
                    <th field="price" width="100">建议评估单价</th>
                    <th field="neirong" width="600" align="center">询价内容及其他</th>
                    <th field="xuntime" width="150" align="center">询价时间</th>
                </tr>
            </thead>
        </table>
    </div>
    <script type="text/javascript">

        //表格
        function getData() {
            var P_ReportNumber = $.query.get("id");//项目号
            var rows = [];
            $.ajax({
                type: "post", //要用post方式                 
                url: "XunJia.aspx/showXunJia",//方法所在页面和方法名
                contentType: "application/json; charset=utf-8",
                data: "{'pnum':'" + P_ReportNumber + "'}",
                dataType: "json",
                async: false,
                success: function (result) {
                    var json = eval("(" + result.d + ")");
                    for (var i = 0; i < json.length; i++) {
                        rows.push({
                            bianId: json[i].inquiry_Id,
                            xiangId: json[i].projectNumber,
                            price: json[i].inquiry_UnitPrice,
                            neirong: json[i].inquiry_Content,
                            xuntime:(new Date(json[i].inquiry_Time)).Format("yyyy-M-d h:m:s.S"),
                        });
                    }
                }
            })
            return rows;
        }

        //新增询价
        function addxun() {
            
            var P_ReportNumber = $.query.get("id");//项目号

            parent.addTab("新增询价", "/DoemsKanCha/AddXunjia.aspx?id=" + P_ReportNumber, "icon-chart-organisation", true);
        }

        function pagerFilter(data) {
            if (typeof data.length == 'number' && typeof data.splice == 'function') {	// is array
                data = {
                    total: data.length,
                    rows: data
                }
            }
            var dg = $(this);
            var opts = dg.datagrid('options');
            var pager = dg.datagrid('getPager');
            pager.pagination({
                onSelectPage: function (pageNum, pageSize) {
                    opts.pageNumber = pageNum;
                    opts.pageSize = pageSize;
                    pager.pagination('refresh', {
                        pageNumber: pageNum,
                        pageSize: pageSize
                    });
                    dg.datagrid('loadData', data);
                }
            });
            if (!data.originalRows) {
                data.originalRows = (data.rows);
            }
            var start = (opts.pageNumber - 1) * parseInt(opts.pageSize);
            var end = start + parseInt(opts.pageSize);
            data.rows = (data.originalRows.slice(start, end));
            return data;
        }

        $(function () {
            if ($.query.get("state") != "已提交/待勘察")
            $("input").attr("disabled", true);
            $("a").attr("disabled", true);
            $('#dg').datagrid({ loadFilter: pagerFilter }).datagrid('loadData', getData());
        });
    </script>
</body>
</html>
